var vm = new Vue({
    el:'#app',
    data:{
        showMask: false,
        username: '',
        newPasswordAgain: '',
        newPassword: '',
        password: ''
    },
    methods: {
        // 点击修改密码
        checnWord:function(){
            this.showMask = true;
            $(".user-opt").hide();
        },
        // 确认
        sure:function(){
            var _this = this;
            if (xmy.trim(_this.newPassword) == '' || xmy.trim(_this.newPasswordAgain) == '' || xmy.trim(_this.password) == '') {
                xmy.toast("请将内容填写完整");
                return false;
            }
            if (xmy.trim(_this.newPassword) != xmy.trim(_this.newPasswordAgain)) {
                xmy.toast("两次输入的新密码不一致");
                return false;
            }
            xmy.getData({
                type: "GET",
                url: api.link + '/sys/user/password',
                data: {
                    password: xmy.trim(_this.password),
                    newPassword: xmy.trim(_this.newPassword)
                },
                success: function(res){
                    if (res.respCode == "000000") {
                        xmy.toast(res.respMsg);
                        _this.password = '';
                        _this.newPassword = '';
                        _this.newPasswordAgain = '';
                        _this.showMask = false;
                    } else {
                        xmy.toast(res.respMsg);
                    }
                }
            })
            
        },
        // 取消
        cancel:function(){
            this.showMask = false;
        },
        // 退出
        logout:function(){
            xmy.getData({
                url: api.link + '/logout?t=' + xmy.getTime(),
                type: 'GET',
                success: function (res) {
                    if (res.respCode == "000000") {
                        window.location.href = './login.html';
                    } else {
                        xmy.toast(res.respMsg);
                    }
                }
            })
        }
    },
    mounted:function(){
        this.username = xmy.getCookie("username");
    }
});